package com.wang.userscenter.common.util;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

/**
 * Io相关的工具类
 */
public class IoUtil {
	/**
	 * 从流中读取信息(字符信息)
	 * @param is
	 * @return
	 */
	public String readContent(InputStream is) {
		StringBuilder sb = new StringBuilder();
		
		BufferedReader br = null;
		try {
			br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
			String line = "";
			while ( ( line = br.readLine() ) != null ) {
				sb.append(line);
			}
			return sb.toString();
		} catch (IOException e) {
			e.printStackTrace();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			try {
				if (br != null) {
					br.close();
					br = null;
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return "";
	}
}
